<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>${sysName}</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="${resRoot}/layui/css/layui.css" media="all" />
  <link rel="stylesheet" href="${resRoot}/layui/admin/admin.css" media="all" />
	<link id="layuicss-layer" rel="stylesheet" href="${resRoot}/layui/css/modules/layer/default/layer.css" media="all">
	<script type="text/javascript" src="${resRoot}/ckeditor/ckeditor.js"></script>
	<script type="text/javascript" src="${resRoot}/ckfinder/ckfinder.js"></script>
</head>
<body>
<div class="layui-fluid">   
          <div class="layui-card">
          <div class="layui-form layui-card-header layuiadmin-card-header-auto"> 
 
<form class="layui-form" action="#" style="margin-top: 20px;margin-bottom:50px;" >
<input type="hidden" id="id" value="<#if fieldInfoDTO??>${fieldInfoDTO.id}<#else></#if>" >
  <div class="layui-form-item">
    <label class="layui-form-label"></label>
    <div class="layui-input-inline">
	      <input type="text" name="tableId" id="tableId" value="<#if fieldInfoDTO?? && fieldInfoDTO.tableId?? >${fieldInfoDTO.tableId! }</#if>" lay-verify="title" autocomplete="off" placeholder="请输入" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">字段名</label>
    <div class="layui-input-inline">
	      <input type="text" name="capitalName" id="capitalName" value="<#if fieldInfoDTO?? && fieldInfoDTO.capitalName?? >${fieldInfoDTO.capitalName! }</#if>" lay-verify="title" autocomplete="off" placeholder="请输入字段名" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入字段名</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">字段类型</label>
    <div class="layui-input-inline">
	      <input type="text" name="columnType" id="columnType" value="<#if fieldInfoDTO?? && fieldInfoDTO.columnType?? >${fieldInfoDTO.columnType! }</#if>" lay-verify="title" autocomplete="off" placeholder="请输入字段类型" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入字段类型</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">注释</label>
    <div class="layui-input-inline">
	      <input type="text" name="comment" id="comment" value="<#if fieldInfoDTO?? && fieldInfoDTO.comment?? >${fieldInfoDTO.comment! }</#if>" lay-verify="title" autocomplete="off" placeholder="请输入注释" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入注释</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">是否覆盖</label>
    <div class="layui-input-inline">
	      <input type="text" name="convertInfo" id="convertInfo" value="<#if fieldInfoDTO?? && fieldInfoDTO.convertInfo?? >${fieldInfoDTO.convertInfo! }</#if>" lay-verify="title" autocomplete="off" placeholder="请输入是否覆盖" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入是否覆盖</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label"></label>
    <div class="layui-input-inline">
	      <input type="text" name="keyFlag" id="keyFlag" value="<#if fieldInfoDTO?? && fieldInfoDTO.keyFlag?? >${fieldInfoDTO.keyFlag! }</#if>" lay-verify="title" autocomplete="off" placeholder="请输入" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label"></label>
    <div class="layui-input-inline">
	      <input type="text" name="keyIdentityFlag" id="keyIdentityFlag" value="<#if fieldInfoDTO?? && fieldInfoDTO.keyIdentityFlag?? >${fieldInfoDTO.keyIdentityFlag! }</#if>" lay-verify="title" autocomplete="off" placeholder="请输入" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">字段名称</label>
    <div class="layui-input-inline">
	      <input type="text" name="name" id="name" value="<#if fieldInfoDTO?? && fieldInfoDTO.name?? >${fieldInfoDTO.name! }</#if>" lay-verify="title" autocomplete="off" placeholder="请输入字段名称" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入字段名称</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">字段名</label>
    <div class="layui-input-inline">
	      <input type="text" name="propertyName" id="propertyName" value="<#if fieldInfoDTO?? && fieldInfoDTO.propertyName?? >${fieldInfoDTO.propertyName! }</#if>" lay-verify="title" autocomplete="off" placeholder="请输入字段名" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入字段名</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">字段类型</label>
    <div class="layui-input-inline">
	      <input type="text" name="propertyType" id="propertyType" value="<#if fieldInfoDTO?? && fieldInfoDTO.propertyType?? >${fieldInfoDTO.propertyType! }</#if>" lay-verify="title" autocomplete="off" placeholder="请输入字段类型" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入字段类型</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">数据库类型</label>
    <div class="layui-input-inline">
	      <input type="text" name="type" id="type" value="<#if fieldInfoDTO?? && fieldInfoDTO.type?? >${fieldInfoDTO.type! }</#if>" lay-verify="title" autocomplete="off" placeholder="请输入数据库类型" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入数据库类型</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">页面标签</label>
    <div class="layui-input-inline">
	      <input type="text" name="htmlType" id="htmlType" value="<#if fieldInfoDTO?? && fieldInfoDTO.htmlType?? >${fieldInfoDTO.htmlType! }</#if>" lay-verify="title" autocomplete="off" placeholder="请输入页面标签" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入页面标签</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">字典</label>
    <div class="layui-input-inline">
	      <input type="text" name="dictValue" id="dictValue" value="<#if fieldInfoDTO?? && fieldInfoDTO.dictValue?? >${fieldInfoDTO.dictValue! }</#if>" lay-verify="title" autocomplete="off" placeholder="请输入字典" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入字典</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">最大长度</label>
    <div class="layui-input-inline">
	      <input type="number" name="maxLength" id="maxLength" value="<#if fieldInfoDTO?? && fieldInfoDTO.maxLength?? >${fieldInfoDTO.maxLength! }</#if>" lay-verify="title" autocomplete="off" placeholder="请输入最大长度" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入最大长度</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">是否允许空</label>
    <div class="layui-input-inline">
	      <input type="text" name="notNull" id="notNull" value="<#if fieldInfoDTO?? && fieldInfoDTO.notNull?? >${fieldInfoDTO.notNull! }</#if>" lay-verify="title" autocomplete="off" placeholder="请输入是否允许空" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入是否允许空</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">列表展示</label>
    <div class="layui-input-inline">
	      <input type="text" name="isShow" id="isShow" value="<#if fieldInfoDTO?? && fieldInfoDTO.isShow?? >${fieldInfoDTO.isShow! }</#if>" lay-verify="title" autocomplete="off" placeholder="请输入列表展示" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入列表展示</div>
  </div>
  

  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" id="submitBtn"  lay-submit=""  type="button">立即提交</button>
      <button type="button" class="layui-btn layui-btn-primary" onclick="backList();" >返回</button>
    </div>
  </div>
</form>
</div>
  </div>
  </div>
<script src="${resRoot}/layui/layui.js" charset="utf-8"></script>
<script src="${resRoot}/js/jquery.min.js?v=2.1.4"></script>
<script type="text/javascript" src="${resRoot}/js/ajaxfileupload.js"></script>
<script>
function backList() {
	layer.closeAll("iframe");
    //刷新父页面
    parent.location.reload();
}

function removeImg(id) {
	layer.confirm('您是确认删除/查看该图片吗？', {
		  btn: ['确认','查看'] //按钮
		}, function(){
			$("#" + id).attr("src", "");
			layer.msg('已删除！');
		}, function(){
			window.open($("#" + id).attr("src"));
		  //layer.msg('已取消！');
		});
}
layui.use(['form', 'layedit', 'laydate', 'upload'], function(){
  var form = layui.form
  ,layer = layui.layer
  ,layedit = layui.layedit
  ,laydate = layui.laydate;
  
  var upload = layui.upload;

  
  
	
  
  //自定义验证规则
  form.verify({
    title: function(value){
      if(value.length == 0){
        return '参数不能为空';
      }
    }
    ,pass: [/(.+){6,12}$/, '密码必须6到12位']
    ,content: function(value){
      layedit.sync(editIndex);
    }
  });
  
  
  
  $("#submitBtn").click(function(){
		var tableId=$("#tableId").val();
	  var id = $("#id").val();
		var capitalName=$("#capitalName").val();
	  var id = $("#id").val();
		var columnType=$("#columnType").val();
	  var id = $("#id").val();
		var comment=$("#comment").val();
	  var id = $("#id").val();
		var convertInfo=$("#convertInfo").val();
	  var id = $("#id").val();
		var keyFlag=$("#keyFlag").val();
	  var id = $("#id").val();
		var keyIdentityFlag=$("#keyIdentityFlag").val();
	  var id = $("#id").val();
		var name=$("#name").val();
	  var id = $("#id").val();
		var propertyName=$("#propertyName").val();
	  var id = $("#id").val();
		var propertyType=$("#propertyType").val();
	  var id = $("#id").val();
		var type=$("#type").val();
	  var id = $("#id").val();
		var htmlType=$("#htmlType").val();
	  var id = $("#id").val();
		var dictValue=$("#dictValue").val();
	  var id = $("#id").val();
		var maxLength=$("#maxLength").val();
	  var id = $("#id").val();
		var notNull=$("#notNull").val();
	  var id = $("#id").val();
		var isShow=$("#isShow").val();
	  var id = $("#id").val();
		var flag = true;
		if(tableId=="" || tableId ==null || tableId =="undefined") {
			layer.alert("请输入！");
		      flag = false;
		      return false;
		}
		if(capitalName=="" || capitalName ==null || capitalName =="undefined") {
			layer.alert("请输入字段名！");
		      flag = false;
		      return false;
		}
		if(columnType=="" || columnType ==null || columnType =="undefined") {
			layer.alert("请输入字段类型！");
		      flag = false;
		      return false;
		}
		if(comment=="" || comment ==null || comment =="undefined") {
			layer.alert("请输入注释！");
		      flag = false;
		      return false;
		}
		if(convertInfo=="" || convertInfo ==null || convertInfo =="undefined") {
			layer.alert("请输入是否覆盖！");
		      flag = false;
		      return false;
		}
		if(keyFlag=="" || keyFlag ==null || keyFlag =="undefined") {
			layer.alert("请输入！");
		      flag = false;
		      return false;
		}
		if(keyIdentityFlag=="" || keyIdentityFlag ==null || keyIdentityFlag =="undefined") {
			layer.alert("请输入！");
		      flag = false;
		      return false;
		}
		if(name=="" || name ==null || name =="undefined") {
			layer.alert("请输入字段名称！");
		      flag = false;
		      return false;
		}
		if(propertyName=="" || propertyName ==null || propertyName =="undefined") {
			layer.alert("请输入字段名！");
		      flag = false;
		      return false;
		}
		if(propertyType=="" || propertyType ==null || propertyType =="undefined") {
			layer.alert("请输入字段类型！");
		      flag = false;
		      return false;
		}
		if(type=="" || type ==null || type =="undefined") {
			layer.alert("请输入数据库类型！");
		      flag = false;
		      return false;
		}
		if(htmlType=="" || htmlType ==null || htmlType =="undefined") {
			layer.alert("请输入页面标签！");
		      flag = false;
		      return false;
		}
		if(dictValue=="" || dictValue ==null || dictValue =="undefined") {
			layer.alert("请输入字典！");
		      flag = false;
		      return false;
		}
		if(maxLength=="" || maxLength ==null || maxLength =="undefined") {
			layer.alert("请输入最大长度！");
		      flag = false;
		      return false;
		}
		if(notNull=="" || notNull ==null || notNull =="undefined") {
			layer.alert("请输入是否允许空！");
		      flag = false;
		      return false;
		}
		if(isShow=="" || isShow ==null || isShow =="undefined") {
			layer.alert("请输入列表展示！");
		      flag = false;
		      return false;
		}
		if(flag) {
			$.ajax({
				type : "post",
				url : "${base}/sys/fieldInfo/save",
				data : {
					tableId : tableId,
					capitalName : capitalName,
					columnType : columnType,
					comment : comment,
					convertInfo : convertInfo,
					keyFlag : keyFlag,
					keyIdentityFlag : keyIdentityFlag,
					name : name,
					propertyName : propertyName,
					propertyType : propertyType,
					type : type,
					htmlType : htmlType,
					dictValue : dictValue,
					maxLength : maxLength,
					notNull : notNull,
					isShow : isShow,
					id : id					
					},
				dataType : "json",
				async : false,
				success : function(data) {
					if(data.message == 2) {
							layer.msg('请完善数据！');   
						} else if(data.message == 1) {
							layer.msg('保存成功！', {
							  icon: 1,
							  time: 2000 //2秒关闭（如果不配置，默认是3秒）
							}, function(){
								backList();
							});   
						} else {
							layer.msg('系统繁忙！'); 
						}
				}
			}); 
		}
	});
  
  
});

layui.use('upload', function(){
	  
});  
</script>
</body>
</html>